package com.boxuegu.concurrent.stop;

public class InterruptThread {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnableThreadImpl = ()->{
            Thread thread = Thread.currentThread();
            // 清除当前线程的中断状态为false
            while (!Thread.interrupted()){
            //while (!thread.isInterrupted()){
                System.out.println("runnable thread");
            }
            System.out.println("线程的终端状态:" + thread.isInterrupted());
        };
        Thread thread = new Thread(runnableThreadImpl);
        thread.start();
        //主线程休眠20ms
        Thread.sleep(20);
        //只能设置线程的终端状态为true
        thread.interrupt();
    }
}
